import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue()
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  server: {
    port: 8080,
    watch: {
      // 忽略一些构建警告
      ignored: ['!**/node_modules/**']
    }
  },
  build: {
    outDir: '../html/vue-dist',
    emptyOutDir: true,
    // 减少构建时的警告输出
    rollupOptions: {
      onwarn(warning, warn) {
        // 忽略一些已知的无害警告
        if (warning.code === 'THIS_IS_UNDEFINED') return
        if (warning.code === 'EVAL') return
        warn(warning)
      }
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        // 抑制Sass弃用警告
        silenceDeprecations: ['legacy-js-api'],
        // 添加更多Sass配置
        api: 'modern-compiler'
      }
    }
  },
  // 设置环境变量来抑制警告
  define: {
    __SILENCE_SASS_DEPRECATIONS__: 'true'
  }
})